#include "mapnameserver.h"
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>
#include <stdlib.h>

using namespace std;
namespace cpp_lab4{
	void MapNameServer::insert(const HostName& host, const IPAddress& address){
		pair<string, int> pair=make_pair(host, address);
		database.insert(pair);
	}
	bool MapNameServer::remove(const HostName& host){
		if(database.erase(host)){
			return true;
		}else{
			return false;
		}
	}
	IPAddress MapNameServer::lookup(const HostName& host)const{
		map<string, int>::const_iterator result;
		result=database.find(host);
		if(result!= database.end()){
			return result->second;
		}else{
			return NON_EXISTING_ADDRESS;
		}
	}
}

